import ms from 'ms';

import sendEmail from './sendEmail';
import isCydEnabled from './isCydEnabled';
import domainOwnershipCheck from './domainOwnershipCheck';
import sendSMS from './sendSMS';
import sendWechatMessage from './sendWechatMessage';
import sendAlert from './sendAlert';
import templateEmails from './emailSendcloud';
import sendSMSBatch from './sendSMSBatch';
import balanceTaskCountUpdate from './balanceTaskCountUpdate';
import * as task from './task';
import { getVulPluginList, getVulPluginCategory } from './vulPlugin';
import usernameSearchFilterArgQuery from './usernameSearchFilterArgQuery';

export default function methodsBuilder(server) {
	server.method('isCydEnabled', isCydEnabled, {
		bind: server,
		cache: { expiresIn: ms('1h'), generateTimeout: 2000 },
	});
	server.method('sendEmail', sendEmail, { bind: server });
	server.method('domainOwnershipCheck', domainOwnershipCheck, {
		bind: server,
	});
	server.method('sendSMS', sendSMS, { bind: server });
	server.method('sendWechatMessage', sendWechatMessage, { bind: server });
	server.method('sendAlert', sendAlert, { bind: server });
	server.method('templateEmails', templateEmails, { bind: server });
	server.method('sendSMSBatch', sendSMSBatch, { bind: server });
	server.method('balanceTaskCountUpdate', balanceTaskCountUpdate, {
		bind: server,
	});
	Object.entries(task).forEach(([name, method]) =>
		server.method(name, method, { bind: server })
	);
	server.method('getVulPluginList', getVulPluginList, {
		bind: server,
	});
	server.method('getVulPluginCategory', getVulPluginCategory, {
		bind: server,
	});
	server.method('usernameSearchFilterArgQuery', usernameSearchFilterArgQuery, {
		bind: server,
	});
}
